|
|
 |
|
|
|
|
' Z coordinates. zok = False
For i = 2 To NumPoints
If Points(i - 1).Trans(3) <> Points(i).Trans(3) _
Then
yok = True
Exit For
End If
Next i
' Test the appropriate projection. If xok And yok Then
PointInside = PointInsideXY(X, Y)
ElseIf yok And zok Then
PointInside = PointInsideYZ(Y, Z)
ElseIf xok And zok Then
PointInside = PointInsideXZ(X, Z)
Else
PointInside = False
End If
End Function
' Return true if the point's projection lies within
' this polygon's projection onto the X-Y plane. Private Function PointInsideXY( _
ByVal X As Single, ByVal Y As Single) As Boolean
Dim i As Integer
Dim theta1 As Double
Dim theta2 As Double
Dim dtheta As Double
Dim dx As Double
Dim dy As Double
Dim angles As Double
dx = Points(NumPoints).Trans(1) - X
dy = Points(NumPoints).Trans(2) - Y
theta1 = ATan2(CSng(dy), CSng(dx))
If theta1 < 0 Then theta1 = theta1 + 2 * PI
For i = 1 To NumPoints
dx = Points(i).Trans(1) - X
dy = Points(i).Trans(2) - Y
theta2 = ATan2(CSng(dy), CSng(dx))
If theta2 < 0 Then theta2 = theta2 + 2 * PI
dtheta = theta2 - theta1
If dtheta > PI Then dtheta = dtheta - 2 * PI
If dtheta < -PI Then dtheta = dtheta + 2 * PI
angles = angles + dtheta
theta1 = theta2
Next i
PointInsideXY = (Abs(angles) > 0.001)
End Function |
|
|
|
|
|